Skip set_mempolicy for phantom NUMA nodes#296
Open
nileshnegi wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents numa_run_on_node() (and the resulting set_mempolicy calls) from being invoked for “phantom” NUMA nodes that aren’t present in the process’ allowed memory-node mask, avoiding EINVAL errors on platforms that expose NUMA nodes without memory backing.
Changes:
- Guard
numa_run_on_node(exeIndex)behind anuma_get_mems_allowed()/numa_bitmask_isbitset()check in the CPU executor path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CollectTopology() probes each NUMA node by allocating a small buffer, which calls numa_set_preferred(i) for all numa_num_configured_nodes(). If some nodes have no memory backing, set_mempolicy(MPOL_PREFERRED) returns EINVAL for them. Guard the call with numa_get_mems_allowed() so only nodes with real memory get a preferred policy set. Co-authored-by: Claude <claude@anthropic.com>
1366134 to
6b60e53
Compare
Comment on lines
+1551
to
+1554
| // Skip memory-less NUMA nodes to avoid set_mempolicy EINVAL | ||
| if (deviceIdx < 0 || numa_bitmask_isbitset(numa_get_mems_allowed(), deviceIdx)) { | ||
| numa_set_preferred(deviceIdx); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fix set_mempolicy EINVAL for memory-less NUMA nodes during topology init
Technical Details
CollectTopology() probes each NUMA node by allocating a small buffer, which calls
numa_set_preferred(i)for allnuma_num_configured_nodes(). If some nodes have no memory backing,set_mempolicy(MPOL_PREFERRED)returns EINVAL for them.Guard the call with
numa_get_mems_allowed()so only nodes with real memory get a preferred policy set.Test Plan
Test Result
Submission Checklist